package com.llap.exp190929.security;

import com.llap.exp190929.util.Util;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * Created by LLAP on 2019/10/14.
 * Copyright (c) 2019 LLAP. All rights reserved.
 */

public class MD5PasswordEncoder implements PasswordEncoder {
    @Override
    public String encode(CharSequence rawPassword) {
        if (rawPassword == null) return "";
        return Util.md5(rawPassword.toString());
    }

    @Override
    public boolean matches(CharSequence rawPassword, String actualPassword) {
        return actualPassword.equals(encode(rawPassword));
    }
}
